﻿<%@ WebHandler Language="C#" Class="OSSBackHandler" %>

using System;
using System.Web;
using Newtonsoft.Json.Linq;
using System.IO;

public class OSSBackHandler : IHttpHandler {

    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "application/json";
        JObject obj = new JObject();
        obj.Add("Status","OK");
        obj.Add("info",context.Request.Form.ToString());
        FileStream fs = new FileStream(context.Server.MapPath("~/log.txt"), FileMode.OpenOrCreate);
        //获得字节数组
        byte[] data = System.Text.Encoding.Default.GetBytes(context.Request.Form.ToString());
        //开始写入
        fs.Write(data, 0, data.Length);
        //清空缓冲区、关闭流
        fs.Flush();
        fs.Close();
        context.Response.Write(obj.ToString());
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}